package com.zzl.study.nacos.config;

import com.zzl.study.nacos.NacosServiceMultiManager;
import com.zzl.study.nacos.discovery.NacosServiceMultiDiscovery;
import com.zzl.study.nacos.properties.NacosMultiDiscoveryProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Nacos多注册中心服务发现自动配置类
 *
 * @author: zhangzl
 * @date: 2025/7/14 22:07
 * @version: 1.0
 */
@Configuration
@EnableConfigurationProperties(NacosMultiDiscoveryProperties.class)
public class NacosMultiDiscoveryAutoConfiguration {

    /**
     * 向Spring容器中注入一个Nacos多注册中心服务发现对象
     *
     * @param nacosMultiDiscoveryProperties Nacos多注册中心服务发现属性对象
     * @param nacosServiceMultiManager      Nacos多注册中心服务管理对象
     * @return Nacos多注册中心服务发现对象
     */
    @Bean
    @ConditionalOnMissingBean
    public NacosServiceMultiDiscovery nacosServiceMultiDiscovery(NacosMultiDiscoveryProperties nacosMultiDiscoveryProperties, NacosServiceMultiManager nacosServiceMultiManager) {
        return new NacosServiceMultiDiscovery(nacosMultiDiscoveryProperties, nacosServiceMultiManager);
    }

}
